;(function () {
	new Vue({
		el: '#jwkAdd',
		data: {			
			serverArr: [{name: ''}],
			demandArr: [{name: ''}],
			industryArr: [],
			companyName: '',
			industryCode: '',
			imgURL: '',
			industryInfo: '',
			isHomepage: 'N'
		},
		methods: {
			blurSeverInputLen (i) {
				if (/\s+/gm.test(this.serverArr[i].name)) {
					hl.toast("请勿填写空格");
					return
				}
				if (hlNumberUtil.fucCheckLength(this.serverArr[i].name) > 12) {
					this.serverArr[i].name = ''
					hl.toast("中文最大为6个字节，英文最大为12个字符");
				}
			},
			blurDemandInputLen (i) {
				if (/\s+/gm.test(this.demandArr[i].name)) {
					hl.toast("请勿填写空格");
					return
				}
				if (hlNumberUtil.fucCheckLength(this.demandArr[i].name) > 12) {
					this.serverArr[i].name = ''
					hl.toast("中文最大为6个字节，英文最大为12个字符");
				}
			},
			//添加服务
			serverAdd () {
				this.serverArr.push({name: ''})
			},
			//删除服务
			serverRemove (i) {
				this.serverArr.splice(i, 1)
			},
			//添加需求
			demandAdd () {
				this.demandArr.push({name: ''})
			},
			//删除需求
			demandRemove (i) {
				this.demandArr.splice(i, 1)
			},
			//上传图片触发
			updateImgEvent () {
				document.querySelector('.updateImg').click()
			},
			//所属行业
			industryDt () {
				hlhttp.get({
					url: 'jwk/company_industrys',
					data: {valid: 'Y'},
					success: (data) => {
						this.industryArr = data;
					}
				})
			},
			//选择行业
			industrySel (item) {
				this.industryCode = item.industryCode
			},
			//是否首页
			addHome () {
				this.isHomepage = this.isHomepage == 'Y' ? 'N' : 'Y';
			},
			//发布
			isSubmit () {
				let serveActive = [], demandActive = [];
				this.serverArr.map(item => {
					if (item.name) {
						serveActive.push(item.name)
					}
				})
				this.demandArr.map(item => {
					if (item.name) {
						demandActive.push(item.name)
					}
				})
				hlhttp.post({
					url: 'jwk/company',
					data: {
						company_name: this.companyName,
						industry_code: this.industryCode,
						logo: this.imgURL,
						serve: serveActive.length ? serveActive.toString() : '#',
						demand: demandActive.length ? demandActive.toString() : '#',
						introduce: this.industryInfo,
						is_homepage: this.isHomepage
					},
					success: (data) => {
						hlUrlUtil.goTo('jwkSquare',{ddtab: true}, false)
					}
				})
			}
		},
		mounted () {
			imgupload0('.updateImg', (data) => {
				this.imgURL = data.json.url
			})
			hlSelectUi()
			this.industryDt()
		}
	})
	
} ())